<?php

namespace app\common\model;

use think\Model;
class ChatGroup extends Model
{
    protected $resultSetType = 'collection';
    public static function chat_group_info($chat_group_id)
    {
        $where = "id = {$chat_group_id}";
        $field = "id,user_id,name,type,add_time,price,user_ids";
        $info = self::where($where)->field($field)->find();
        if($info['user_ids']){
            $group_member = User::where("user_id","IN",$info["user_ids"])->field("username,image,industry_id,company_typeid,position_id")->select();
            $group_count = count($group_member);
            $info['group_member'] = $group_member;
            $info['group_count'] = $group_count;
        }else{
            $info['group_member'] = [];
            $info['group_count'] = 0;
        }
        return $info;
    }

    public function getAddTimeAttr($value)
    {
        if($value){
            return date("Y年m月d日 H:i:s",$value);
        }else{
            return "";
        }
    }
}
